<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2012-1-16
  Time: 11:59:04
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/inc/taglibs.jsp" %>
<link href="${path}/css/tree.css" rel="stylesheet" type="text/css">
<link href="${path}/css/ztree/zTreeStyle.css" rel="stylesheet" type="text/css">
<c:choose>
    <c:when test="${empty model}">
        <c:set var="action" value="${path }/admin/hotel/add"></c:set>
    </c:when>
    <c:otherwise>
        <c:set var="action" value="${path }/admin/hotel/update"></c:set>
    </c:otherwise>
</c:choose>
<div class="pageContent">
    <form method="post" action="${action}" class="pageForm required-validate"
          onsubmit="return iframeCallback(this, resHandler);">
        <div class="pageFormContent" layoutH="56">
            <table>
                <tr>
                    <td>
                        <label>酒店名称：</label>
                    </td>
                    <td>
                        <input type="text" name="name" id="name" size="40" value="${model.name}">
                    </td>
                </tr>
                <tr>
                    <td>
                        <label>所在地区：</label>
                    </td>
                    <td>
                        <input name="areaName" id="areaName" type="text" value="${model.areaName}"/>
                        <input type="hidden" name="area" id="area" size="40" value="${model.area}">
                        <a id="areaBtn" href="javascript:void(0)" onclick="showAreaMenu()">选择</a>
                    </td>
                </tr>
                <tr>
                    <td>

                    </td>
                    <td>
                        <div id="areaContent" class="menuContent" style="display:none;">
                            <ul id="treeArea" class="ztree" style="margin-top:0; width:160px;"></ul>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <label>价格：</label>
                    </td>
                    <td>
                        <input name="price" type="text" size="40" value="${model.price}"/>
                    </td>
                </tr>
                <tr>
                    <td>
                        <label>描述：</label>
                    </td>
                    <td>
                       <textarea rows="4" cols="40" name="memo">${model.memo}</textarea>
                    </td>
                </tr>
                <tr>
                    <td>
                        <label>图片：</label>
                    </td>
                    <td>
                        <input id="imgUploader" type="file" fileDataName="imgFile"
							uploader="${path }/js/dwz/uploadify/scripts/uploadify.swf"
							cancelImg="${path }/js/dwz/uploadify/cancel.png"
							buttonImg="${path }/img/upload.png"
							width="64"
							height="32"
							script="${path }/upload/image"
							scriptData=""
							fileQueue="fileQueue"
							fileExt="*.jpg;*.jpeg;*.gif;*.png;"
							fileDesc="*.jpg;*.jpeg;*.gif;*.png;"
							onComplete="uploadImgFinish"
							/>
						<input type="text" readonly="readonly" name="img" id="img" value="${model.img}">
                    </td>
                </tr>
                <tr>
                    <td>

                    </td>
                    <td>
                         <c:if test="${!empty model}">
                               <div id="pic" class="boximg" style="width:170px;height:150px;overflow:hidden;">
                                   <img src="${uploadHttp}${model.img}"/>
                               </div>
                        </c:if>
                    </td>
                </tr>
                <tr>
                    <td>
                        <label>pdf附件：</label>
                    </td>
                    <td>
                        <input id="pdfUploader" type="file" fileDataName="pdfFile"
							uploader="${path }/js/dwz/uploadify/scripts/uploadify.swf"
							cancelImg="${path }/js/dwz/uploadify/cancel.png"
							buttonImg="${path }/img/upload.png"
							width="64"
							height="32"
							script="${path }/upload/pdf"
							scriptData=""
							fileQueue="fileQueue"
							fileExt="*.pdf"
							fileDesc="*.pdf"
							onComplete="uploadPdfFinish"
							/>
						<input type="text" readonly="readonly" name="pdf" id="pdf" value="${pdf}">
                    </td>
                </tr>
                <tr>
                    <td>

                    </td>
                    <td>
                        <div id="fileQueue" class="fileQueue" style="height:100px"></div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <label>是否置顶</label>
                    </td>
                    <td>
                        <input type="radio" name="istop" value="0" <c:if test="${empty model ||model.istop==0}">checked</c:if> >否
                        <input type="radio" name="istop" value="1" <c:if test="${model.istop==1}">selected</c:if> >是
                    </td>
                </tr>
                <tr>
                    <td>
                        <label>是否推介</label>
                    </td>
                    <td>
                        <input type="radio" name="ispush" value="0" <c:if test="${empty model ||model.ispush==0}">checked</c:if> >否
                        <input type="radio" name="ispush" value="1" <c:if test="${model.ispush==1}">selected</c:if> >是
                    </td>
                </tr>
                <c:if test="${!empty model}">
                    <tr>
                        <td>

                            <input type="hidden" name="id" value="${model.id}">
                        </td>
                    </tr>
                </c:if>
            </table>
        </div>
        <div class="formBar">
            <ul>
                <li>
                    <div class="buttonActive">
                        <div class="buttonContent">
                            <button type="submit">保存</button>
                        </div>
                    </div>
                </li>
                <li>
                    <div class="button">
                        <div class="buttonContent">
                            <button type="button" class="close">取消</button>
                        </div>
                    </div>
                </li>
            </ul>
        </div>
    </form>
</div>
<script type="text/javascript" src="${path}/js/jquery.autoIMG.js"></script>
<script type="text/javascript" src="${path}/js/ztree/jquery.ztree.core-3.0.js"></script>
<script type="text/javascript">
    /**
     *地区树参数1.
     */
    var setting = {
        async: {
            enable: true,
            url:"${path}/admin/area/nodes.json",
            autoParam:["id", "name=n", "level=lv"],
            otherParam:{"otherParam":"zTreeAsyncTest"}
            //dataFilter: filter
        },
        callback:{
            onClick: areaOnClick
        }
    };

    /**
     * 起飞地树点击.
     * @param e
     * @param treeId
     * @param treeNode
     */
    function areaOnClick(e, treeId, treeNode) {
        var zTree = $.fn.zTree.getZTreeObj(treeId);
        nodes = zTree.getSelectedNodes();
        if (nodes.length > 1) {
            alert("只能选择一个地区");
        }
        v = nodes[0].name;
        i = nodes[0].id;
        $("#areaName").attr("value", v);
        $("#area").attr("value", i);
        $("#areaContent").toggle("fast");
    }

     /**
     * 地区选择.
     */
    function showAreaMenu() {
        $("#areaContent").toggle("fast");
    }


    $(document).ready(function(){
        $.fn.zTree.init($("#treeArea"), setting);
    });
    function resHandler(response) {
        alertMsg.correct('您的数据提交成功！');
        navTab.reload("${path}/admin/hotel", "");
        $.pdialog.closeCurrent();
    }
    function uploadImgFinish(event,id,fileObj,response,data){
		var responseJson =$.parseJSON(response);
		$("#img").val(responseJson[0]);
	}
    function uploadPdfFinish(event,id,fileObj,response,data){
        var responseJson =$.parseJSON(response);
		$("#pdf").val(responseJson[0]);
    }

    $(".boximg").autoIMG();
</script>
